﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Threading.Tasks;
using System.Threading;
using System.Diagnostics;

namespace T.FAS.Runtime.DataAccess.Common
{
    internal class CDOConstFac
    {
        private static readonly Dictionary<OpeType, IMonitorConst> s_cache = new Dictionary<OpeType, IMonitorConst>
        {
            { OpeType.Create, new CDOAddMonitorConst() },
            { OpeType.Retrieve, new CDORetrieveMonitorConst() },
            { OpeType.Update, new CDOUpdateMonitorConst() },
            { OpeType.Delete, new CDODeleteMonitorConst() },
        };
        private static readonly IMonitorConst s_main = new CDOMonitorConst();

        public static IMonitorConst GetCDOMonitorConst(OpeType type)
        {
            return s_cache[type];
        }

        public static IMonitorConst GetCDOMonitorConst()
        {
            return s_main;
        }
    }

    public class ContextInfo
    {
        public static readonly string ApplicationName = Process.GetCurrentProcess().ProcessName;
    }

    internal interface IMonitorConst : ITPS, IDuration, ITrace
    {

    }

    internal class CDOAddMonitorConst : IMonitorConst
    {
        public string TPS { get; set; } = "FAS.CDO.Invoke.Add.TPS";
        public string Duration { get; set; } = "FAS.CDO.Invoke.Add.Duration";
        public string Trace { get; set; } = "FAS.CDO.Invoke.Add.Trace";
    }
    internal class CDODeleteMonitorConst : IMonitorConst
    {
        public string TPS { get; set; } = "FAS.CDO.Invoke.Delete.TPS";
        public string Duration { get; set; } = "FAS.CDO.Invoke.Delete.Duration";
        public string Trace { get; set; } = "FAS.CDO.Invoke.Delete.Trace";
    }
    internal class CDOUpdateMonitorConst : IMonitorConst
    {
        public string TPS { get; set; } = "FAS.CDO.Invoke.Update.TPS";
        public string Duration { get; set; } = "FAS.CDO.Invoke.Update.Duration";
        public string Trace { get; set; } = "FAS.CDO.Invoke.Update.Trace";
    }
    internal class CDORetrieveMonitorConst : IMonitorConst
    {
        public string TPS { get; set; } = "FAS.CDO.Invoke.Retrieve.TPS";
        public string Duration { get; set; } = "FAS.CDO.Invoke.Retrieve.Duration";
        public string Trace { get; set; } = "FAS.CDO.Invoke.Retrieve.Trace";
    }

    internal interface ITPS
    {
        string TPS { get; set; }
    }

    internal interface IDuration
    {
        string Duration { get; set; }
    }

    internal interface ITrace
    {
        string Trace { get; set; }
    }

    /// <summary>
    /// 插件注入方法
    /// </summary>
    public enum OpeType
    {
        Create = 0,
        Update = 1,
        Delete = 2,
        Retrieve = 3,
    }
}